package com.yida.system.api.factory;

import com.yida.common.core.domain.R;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.system.api.RemoteUserOutsideOfficerService;
import com.yida.system.api.domain.SysUserCommunity;
import com.yida.system.api.domain.request.BindCommunityRequest;
import com.yida.system.api.domain.request.RegisterBindRequest;
import com.yida.system.api.domain.request.SysUserOutsideOfficerRemoveRequest;
import com.yida.system.api.domain.request.SysUserQueryRequest;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Description 外用用户管理降级
 * @Author wws
 * @Date 2023-06-17
 */
@Component
public class RemoteUserOutsideOfficerFallbackFactory implements FallbackFactory<RemoteUserOutsideOfficerService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteUserFallbackFactory.class);
    @Override
    public RemoteUserOutsideOfficerService create(Throwable throwable) {
        return new RemoteUserOutsideOfficerService() {
            @Override
            public R<TableDataInfo> innerList(SysUserQueryRequest request, String source) {
                return R.fail("列表查询失败:" + throwable.getMessage());
            }

            @Override
            public R innerBindCommunity(BindCommunityRequest request, String source) {
                return R.fail("项目绑定失败" + throwable.getMessage());
            }

            @Override
            public R<List<SysUserCommunity>> innerGetBindCommunities(Long userId, String source) {
                return R.fail("已绑定用户查询失败" + throwable.getMessage());
            }

            @Override
            public R innerRegisterAndBind(RegisterBindRequest request, String source) {
                return R.fail("用户注册失败" + throwable.getMessage());
            }

            @Override
            public R innerRemoveOutsideUser(SysUserOutsideOfficerRemoveRequest request, String source) {
                return R.fail("用户删除失败" + throwable.getMessage());
            }
        };
    }
}
